<template>
  <div>
    <v-header></v-header>
    <div class="content">
      <router-link tag="div" :to="'./detail2/'+item.sid"
        v-for="(item, index) in news" :key="index" class="content-itme">
        <div class="left-content">
          <div class="title">{{item.text}}</div>
        </div>
        <img v-if="item.images" :src="item.images" class="joke-img">
      </router-link>
    </div>
  </div>
</template>

<script>
import vHeader from './header'
import axios from 'axios'
import {getJoke} from '../../sever'
export default {
  data () {
    return {
      news: []
    }
  },
  components: {
    vHeader
  },
  created() {
    this.getNews();
  },
  methods: {
    getNews() {
      // return
      axios.post(getJoke, {
        type: 'text',
        count: 5
      })
        .then(res => {
          console.log(res.data)
          this.news = res.data.result
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}
</script>

<style scoped>
  .top-bar {
    width: 100%;
    height: 45px;
    line-height: 45px;
    background-color: #000;
    color: #fff;
  }
  .content {
    width: 600px;
    margin: 0 auto;
    border: 1px solid #eee;
  }
  .content-itme {
    padding: 10px;
    height: 90px;
    border-bottom: 1px solid #eee;
  }
  .joke-img {
    float: right;
    width: 140px;
    height: 88px;
    margin-left: 20px;
  }
  .left-content {
    float: left;
    text-align: left;
    width: 380px;
  }
  .title {
    margin-bottom: 50px;
  }
</style>
